import React from "react";
import { basicIp, newHttpService } from "../../api/http";

///ksh/set
export const getKshSet = (data: {
  id: React.Key;
  key: string;
  value: string | boolean;
}) => {
  const url = basicIp + "/ksh/set";
  return newHttpService.getData(url, data);
};

//ksh/getRTSP
export const getKshGetRTSP = (data: { id: React.Key }) => {
  const url = basicIp + "/ksh/getRTSP";
  return newHttpService.getData(url, data);
};

//ksh/loadButton
export const postKshLoadButton = (data: {
  channelNo: string;
  loadType: string;
}) => {
  const url = basicIp + "/ksh/loadButton";
  return newHttpService.postData(url, data);
};
// 雷达监测状态
export interface IKshRadarStatus {
  coalStatus: number; // 底留煤检查状态(0:正常 1:异常)
  reinforcementStatus: number; // 加强筋检测状态(0:有 1:无)
  tarpaulinStatus: number; // 篷布检查状态(0:正常 1:异常)
}
export const getKshRadarStatus = (data: { id: React.Key }) => {
  const url = basicIp + "/ksh/radarStatus";
  return newHttpService.getData(url, data);
};
// 获取装车站状态
export interface IKshLoadStatus {
  loadStatus: number; // 装车站状态(0:空车 1:有车)
}
export const postKshLoadStatus = (data: { id: React.Key }) => {
  const url = basicIp + "/ksh/loadStatus";
  return newHttpService.getData(url, data);
};
// 改变装车站状态
export const getKshSwitchLoadStatus = (data: {
  id: React.Key;
  status: number;
}) => {
  const url = basicIp + "/ksh/switchLoadStatus";
  return newHttpService.getData(url, data);
};

// 空气炮开关
export interface IKshKqpControlPrams {
  id: string;
  number: string;
  status: string; // 状态 0:开启 1:关闭
}
export const getKshKqpControl = (data: IKshKqpControlPrams) => {
  const url = basicIp + "/ksh/kqpControl";
  return newHttpService.getData(url, data);
};

// 校准给煤机
export interface IKshCalibrationPrams {
  id: React.Key;
  number: number;
  beltWeight: number;
  scsWeight: number;
}
export const getKshCalibration = (data: IKshCalibrationPrams) => {
  const url = basicIp + "/ksh/Calibration";
  return newHttpService.postData(url, data);
};
// 手动抬杆
export const getKshHandLift = (data: { id: React.Key, type: 0 | 1 }) => {
  const url = basicIp + "/ksh/handLift";
  return newHttpService.getData(url, data);
};

// 卷帘门开启 关闭
export interface IKshKaiMenPrams {
  id: React.Key;
  status: number; // 状态 0:开启 1：关闭
  number: number; // 编号 1:1号 2:2号
  type: number; // 类型 0:上升 1：下降
}
export const getKshKaiMen = (data: IKshKaiMenPrams) => {
  const url = basicIp + "/ksh/kaiMen";
  return newHttpService.getData(url, data);
};

// 获取校准状态
export interface IKshPrepareStatusParams {
  id: React.Key;
  number: number; // 给煤机编号 1:1号 2:2号
}
export const getKshPrepareStatus = (data: IKshPrepareStatusParams) => {
  const url = basicIp + "/ksh/prepareStatus";
  return newHttpService.getData(url, data);
};
// 获取车辆地磅和皮带秤重量
export interface IKshGetWeightParams {
  carColor: string; // 车牌颜色
  carNo: string; // 车牌号
}
export interface IKshGetWeight {
  time: string; //时间string(date-time)
  type: string; //类型string($enum) 0:地磅 1:皮带秤
  weight: number; //重量
}
export const postKshGetWeight = (data: IKshGetWeightParams) => {
  const url = basicIp + "/ksh/getWeight";
  return newHttpService.postData(url, data);
};
// 开始校准
export interface IKshStartCalibrationParams {
  id: React.Key;
  number: number; // 给煤机编号 1:1号 2:2号
}
export const getKshStartCalibration = (data: IKshStartCalibrationParams) => {
  const url = basicIp + "/ksh/startCalibration";
  return newHttpService.getData(url, data);
};

// 获取加热冷却状态
export const getKshJrLqStatus = (data: { id: React.Key }) => {
  const url = basicIp + "/ksh/jrLqStatus";
  return newHttpService.getData(url, data);
};
// 加热冷却状态切换
export interface IKshSwitchJrLqStatusParams {
  id: React.Key;
  type: 0 | 1; // 0 加热 1 冷却
  status: 0 | 1; // 0：自动 1：手动
}
export interface IKshSwitchJrLqStatus {
  kqpStatus: 1 | 2 | 3; // 1：代表手动 2：堵料模式 3：间歇模式
  dlTime: number; // 堵料等待时间秒
  jgTime: number; // 间歇时间秒
  id: React.Key; //装车站ID
  jrStatus: 0 | 1; // 0：自动 1：手动
  lqStatus: 0 | 1; // 0：自动 1：手动
}
export const getKshSwitchJrLqStatus = (data: IKshSwitchJrLqStatusParams) => {
  const url = basicIp + "/ksh/switchJrLqStatus";
  return newHttpService.getData(url, data);
};
// 设置空气炮模式
export interface IKshSetKqpParamParams {
  dlTime: number; // 堵料等待时间秒
  jgTime: number; // 间隔时间秒
  kqpStatus: 1 | 2 | 3; // 1：代表手动 2：堵料模式 3：间歇模式
  id: React.Key; //装车站ID
}
export const postKshSetKqpParam = (data: IKshSetKqpParamParams) => {
  const url = basicIp + "/ksh/setKqpParam";
  return newHttpService.postData(url, data);
};
// // 读取偏移值
// export const getKshGetPCZ = (data: { id: React.Key }) => {
//   const url = basicIp + "/ksh/getPCZ";
//   return newHttpService.getData(url, data);
// }
// 设置偏移值
export const getKshSetPCZ = (data: { id: React.Key; value: string }) => {
  const url = basicIp + "/ksh/setPCZ";
  return newHttpService.getData(url, data);
}
// 获取模板下载地址
export const getKshGetRTSPAddr = () => {
  const url = basicIp + '/ksh/getRTSPAddr';
  return newHttpService.getData(url);
}